const { defineConfig } = require("@vue/cli-service");
module.exports = defineConfig({

    // babel-loader不理会node_modules目录
    transpileDependencies: false,

    // 更改输出位置
    outputDir: "D:/phpStudy/WWW/jdzb_client_vue",

    // 不输出sourceMap文件
    productionSourceMap: false,

    // 开发服务器
    devServer: {
        proxy: {
            "/api": {
                target: "http://10.3.134.65:9000/api",
                ws: true,
                changeOrigin: true,
                pathRewrite: {
                    "^/api": "",
                },
            },
            "/img": {
                target: "http://10.3.134.65:5000/img",
                ws: true,
                changeOrigin: true,
                pathRewrite: {
                    "^/img": "",
                },
            },
        },
    },

    chainWebpack: config => {
        config.optimization.splitChunks({
            chunks: "all",
            cacheGroups: {
                vendor: {
                    name: "chunk-vendor", // chunk 名称
                    priority: 1, // 权限更高，优先抽离，重要！！！
                    test: /[\\/]node_modules[\\/]/,
                    minSize: 0, // 大小限制
                    minChunks: 1, // 最少复用过几次
                },

                // 公共的模块
                common: {
                    name: "chunk-common", // chunk 名称
                    test: /[\\/]src[\\/]utils[\\/]/,
                    priority: 2, // 优先级
                    minSize: 0, // 公共模块的大小限制
                    minChunks: 1, // 公共模块最少复用过几次
                },

                elementPlus: {
                    name: "chunk-element-plus",
                    priority: 20,
                    test: /[\\/]node_modules[\\/]element-plus[\\/]/
                }
            }
        })
    }

});
